package com.jike.shop.cloud.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jike.shop.cloud.annotation.Master;
import com.jike.shop.cloud.entity.DemoOrder;
import com.jike.shop.cloud.mapper.DemoOrderMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DataSourceServiceImpl extends ServiceImpl<DemoOrderMapper, DemoOrder> implements DataSourceService {
    /**
     * 保存
     * @param orderInfo
     * @return  是否成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrderInfo(DemoOrder orderInfo){
        return this.save(orderInfo);
    }

    /**
     * 删除
     *
     * @param id id
     * @return 是否成功
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteOrderInfo(Long id) {
        return this.removeById(id);
    }

    /**
     * 查询全部
     *
     * @return 全部
     */
    @Override
    public List<DemoOrder> getOrderInfoAll() {
        return this.list();
    }

    /**
     * 查询单个
     *
     * @param id id
     * @return 商品
     */
    @Master
    @Override
    public DemoOrder getOrderInfoById(Long id) {
        return this.getById(id);
    }

}
